package basic_1024;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scanner=new Scanner(System.in);
		
		String[] num1=scanner.next().split("/");
		String[] num2=scanner.next().split("/");
		
		scanner.close();
		
		Number number1=new Number(Integer.parseInt(num1[1]), Integer.parseInt(num1[0]));
		Number number2=new Number(Integer.parseInt(num2[1]), Integer.parseInt(num2[0]));
		
		String n1Normal=number1.getNormal();
		String n2Normal=number2.getNormal();
		System.out.println(n1Normal+" + "+n2Normal+" = "+Number.add(number1, number2).getNormal());
		System.out.println(n1Normal+" - "+n2Normal+" = "+Number.cut(number1, number2).getNormal());
		System.out.println(n1Normal+" * "+n2Normal+" = "+Number.multiply(number1, number2).getNormal());
		System.out.println(n1Normal+" / "+n2Normal+" = "+Number.divide(number1, number2).getNormal());
		
	}
	
	static class Number{
		boolean Negtive=false;
		int mom;
		int son;
		Number(int mom,int son){
			this.mom=mom;
			this.son=son;
			if(son<0) {
				Negtive=true;
			}
			if(this.mom<0) {
				this.mom=-this.mom;
				this.son=-this.son;
				Negtive=true;
			}
		}
		
		String getNormal() {
			if(mom==0) {
				return "Inf";
			}
			String value="";
			if(son%mom==0) {
				value=""+(son/mom);
			}else {
				Minisize();
				if(Math.abs(son)<mom) {
						value=son+"/"+mom;
				}else {
					int com=son/mom;
					int newSon=Math.abs(son)%mom;
	
					value=com+" "+newSon+"/"+mom;
				}
			}
			if(Negtive) {
				value="("+value+")";
			}
			return value;
		}
		
		void Minisize() {
			if(mom==0) return;
			for(int i=mom-1;i>=2;i--) {
				if(mom%i==0&&son%i==0) {
					mom=mom/i;
					son=son/i;
				}
			}
		}
		
		static Number add(Number num1,Number num2) {
			Number number=new Number(num1.mom*num2.mom, num1.son*num2.mom+num1.mom*num2.son);
			return number;
		}
		static Number multiply(Number num1,Number num2) {
			Number number=new Number(num1.mom*num2.mom, num1.son*num2.son);
			return number;
		}
		static Number cut(Number num1,Number num2) {
			Number number=new Number(num1.mom*num2.mom, num1.son*num2.mom-num1.mom*num2.son);
			return number;
		}
		static Number divide(Number num1,Number num2) {
			Number number=new Number(num1.mom*num2.son, num1.son*num2.mom);
			return number;
		}
	}
}
